#ifndef LOG_MESSAGE_POOL_H
#define LOG_MESSAGE_POOL_H

#include "log_message_block.h"
//#include <boost/pool/object_pool.hpp>
#include "utils/object_pool.hpp"
#include "utils/index_object_pool_alloc.hpp"
using namespace vpm::utils;
namespace vpm
{
	namespace log 
	{
		namespace detail 
		{
			class LogMessagePool
			{
			public:
				enum {

					LOG_MSG_POOL_SIZE = 4096,
				};
				LogMessagePool()
				{

				}

				LogMessageBlock *require_message_block()
				{
					//TODO exception ? 
					//return (new (m_msgPool.malloc())LogMessageBlock());

					return m_msgPool.malloc();
				}
				template<class Param1>
				LogMessageBlock * require_message_block(Param1 p1 )
				{
					//return (new (m_msgPool.malloc())LogMessageBlock(p1));
					return m_msgPool.malloc(p1);
				}
				template<class Param1,class Param2>
				LogMessageBlock * require_message_block(Param1 p1,Param2 p2 )
				{
					//return (new (m_msgPool.malloc())LogMessageBlock(p1,p2));
					return m_msgPool.malloc(p1,p2);
				}

				template<class Param1,class Param2,class Param3>
				LogMessageBlock * require_message_block(Param1 p1,Param2 p2 ,Param3 p3)
				{
					//return (new (m_msgPool.malloc())LogMessageBlock(p1,p2,p3));
					return m_msgPool.malloc(p1,p2,p3);
				}

				void release_message_block(LogMessageBlock *pLogMsg)
				{		
					m_msgPool.free(pLogMsg);
				}

			private:
				//boost::object_pool<LogMessageBlock>  m_msgPool; 
				ObjectPool<LogMessageBlock,IndexObjectPoolAllocator<LogMessageBlock> > m_msgPool;
				//ObjectPool<LogMessageBlock > m_msgPool;
			};
		}
	}
}

#endif //
  
  
  
